﻿using System;
using System.Windows;
using N3P.WCF.Proxyless.FullFramework45;
using ServiceContracts;

namespace WpfApplication2
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow
    {
        public MainWindow()
        {
            InitializeComponent();

            //Uncomment the line below to demand that the client's definition be created now, this is a "fire and forget" style async call
            //WcfClient<IService1>.CreateClientAsync();
        }

        private async void ButtonClick(object sender, RoutedEventArgs e)
        {
            var client = new WcfClient<IService1>();

            try
            {
                var result = await client.CallAsync(x => x.ProcessString(MyTextBox.Text));
                MyTextBlock.Text = result;
            }
            catch (Exception ex)
            {
                MyTextBlock.Text = ex.Message;
            }
        }
    }
}
